home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
program
/
progem.lzh
/
rscvmain.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-06-23
|
15KB
|
723 lines
/*------------------------------*/
/* includes */
/*------------------------------*/
#include "portab.h" /* portable coding conv */
#include "machine.h" /* machine depndnt conv */
#include "obdefs.h" /* object definitions */
#include "gembind.h" /* gem binding structs */
#include "osbind.h" /* BDOS definitions */
#include "gemdefs.h"
#include "rsconv.h"
/*------------------------------*/
/* defines */
/*------------------------------*/
#define NIL -1
#define DESK 0
#define ARROW 0
#define HOUR_GLASS 2
#define END_UPDATE 0
#define BEG_UPDATE 1
typedef struct memform
{
WORD *mp;
WORD fwp;
WORD fh;
WORD fww;
WORD ff;
WORD np;
WORD r1;
WORD r2;
WORD r3;
} MFDB;
/*------------------------------*/
/* Global */
/*------------------------------*/
GLOBAL WORD gl_apid;
GLOBAL WORD contrl[11]; /* control inputs */
GLOBAL WORD intin[80]; /* max string length */
GLOBAL WORD ptsin[256]; /* polygon fill points */
GLOBAL WORD intout[45]; /* open workstation output */
GLOBAL WORD ptsout[12];
GLOBAL WORD gl_wchar; /* character width */
GLOBAL WORD gl_hchar; /* character height */
GLOBAL WORD gl_wbox; /* box (cell) width */
GLOBAL WORD gl_hbox; /* box (cell) height */
GLOBAL WORD gem_handle; /* GEM handle */
GLOBAL WORD vdi_handle; /* VDI handle */
GLOBAL WORD work_out[57]; /* open virt workstation values */
GLOBAL GRECT scrn_area; /* scrn area */
GLOBAL MFDB scrn_mfdb; /* scrn memory def'n for blt */
GLOBAL GRECT full; /* desktop size */
/*------------------------------*/
/* External */
/*------------------------------*/
EXTERN WORD desel_obj();
/*------------------------------*/
/* Local */
/*------------------------------*/
MLOCAL WORD native_in = TRUE; /* TRUE: input .RSC is native */
/* FALSE: input .RSC is foreign */
MLOCAL WORD conv_def = TRUE; /* TRUE: convert .DEF also */
MLOCAL WORD new_dfn = FALSE; /* TRUE: use new symbol fmt */
MLOCAL BYTE old_rsc[4] = "RSC"; /* new resource file extent */
MLOCAL BYTE new_rsc[4] = "RS2"; /* new resource file extent */
MLOCAL BYTE old_def[4] = "DEF"; /* new definition file extend */
MLOCAL BYTE new_def[4] = "DF2"; /* new definition file extend */
MLOCAL BYTE r_file[81]; /* resource file name */
MLOCAL BYTE d_file[81]; /* definition file name */
MLOCAL BYTE r2_file[81]; /* output resource name */
MLOCAL BYTE d2_file[81]; /* output definition name */
MLOCAL WORD r_hndl = -1; /* resource file handle */
MLOCAL WORD d_hndl = -1; /* definition file handle */
MLOCAL WORD r2_hndl = -1; /* output resource handle */
MLOCAL WORD d2_hndl = -1; /* output definition handle */
MLOCAL LONG f_err; /* file error */
MLOCAL BYTE *head; /* location of buffer */
MLOCAL LONG buff_size; /* size of buffer */
MLOCAL BYTE buff[20]; /* def file work area */
MLOCAL UWORD img_offset, addr; /* for image fixup */
MLOCAL WORD img_odd; /* image fixup needed? */
MLOCAL GRECT prog_rect; /* rectangle for prog indicator */
/*------------------------------*/
/* swap_bytes */
/*------------------------------*/
VOID
swap_bytes(where, len)
BYTE *where;
WORD len;
{
BYTE swap;
for (; len > 0; len -= 2)
{
swap = *where;
*where = *(where + 1);
*(where + 1) = swap;
where += 2;
}
}
/*------------------------------*/
/* swap_words */
/*------------------------------*/
VOID
swap_words(where, len)
WORD *where;
WORD len;
{
UWORD swap;
for (; len > 0; len -= 4)
{
swap = *where;
*where = *(where + 1);
*(where + 1) = swap;
where += 2;
}
}
/*------------------------------*/
/* swap_images */
/*------------------------------*/
VOID
swap_images()
{
BITBLK *where;
ICONBLK *where2;
BYTE *taddr;
WORD num;
WORD wb, hl;
where = (BITBLK *) (head + ((RSHDR *) head)->rsh_bitblk);
num = ((RSHDR *) head)->rsh_nbb;
for (; num--; where++)
{
taddr = where->bi_pdata;
wb = where->bi_wb;
hl = where->bi_hl;
if ((LONG) taddr != -1L)
{
if (img_odd)
where->bi_pdata = ++taddr;
swap_bytes(head + taddr, wb * hl);
}
}
where2 = (ICONBLK *) (head + ((RSHDR *) head)->rsh_iconblk);
num = ((RSHDR *) head)->rsh_nib;
for (; num--; where2++)
{
wb = (where2->ib_wicon + 7) >> 3;
hl = where2->ib_hicon;
taddr = where2->ib_pdata;
if ((LONG) taddr != -1L)
{
if (img_odd)
where2->ib_pdata = ++taddr;
swap_bytes(head + taddr, wb * hl);
}
taddr = where2->ib_pmask;
if ((LONG) taddr != -1L)
{
if (img_odd)
where2->ib_pmask = ++taddr;
swap_bytes(head + taddr, wb * hl);
}
}
}
/*------------------------------*/
/* swap_trees */
/*------------------------------*/
VOID
swap_trees()
{
BYTE *where;
WORD size;
where = head + ((RSHDR *) head)->rsh_trindex;
size = ((RSHDR *) head)->rsh_ntree * sizeof(LONG);
swap_bytes(where, size);
swap_words((WORD *) where, size);
}
/*------------------------------*/
/* swap_objs */
/*------------------------------*/
VOID
swap_objs()
{
OBJECT *where;
WORD num;
where = (OBJECT *) (head + ((RSHDR *) head)->rsh_object);
num = ((RSHDR *) head)->rsh_nobs;
swap_bytes((BYTE *) where, num * sizeof(OBJECT));
for (; num--; where++)
swap_words((WORD *) &where->ob_spec, sizeof(LONG));
}
/*------------------------------*/
/* swap_teds */
/*------------------------------*/
VOID
swap_teds()
{
TEDINFO *where;
WORD num;
where = (TEDINFO *) (head + ((RSHDR *) head)->rsh_tedinfo);
num = ((RSHDR *) head)->rsh_nted;
swap_bytes((BYTE *) where, num * sizeof(TEDINFO));
for (; num--; where++)
{
swap_words((WORD *) &where->te_ptext, sizeof(LONG));
swap_words((WORD *) &where->te_ptmplt, sizeof(LONG));
swap_words((WORD *) &where->te_pvalid, sizeof(LONG));
}
}
/*------------------------------*/
/* swap_ibs */
/*------------------------------*/
VOID
swap_ibs()
{
ICONBLK *where;
WORD num;
where = (ICONBLK *) (head + ((RSHDR *) head)->rsh_iconblk);
num = ((RSHDR *) head)->rsh_nib;
swap_bytes((BYTE *) where, num * sizeof(ICONBLK));
for (; num--; where++)
{
swap_words((WORD *) &where->ib_pdata, sizeof(LONG));
swap_words((WORD *) &where->ib_pmask, sizeof(LONG));
swap_words((WORD *) &where->ib_ptext, sizeof(LONG));
}
}
/*------------------------------*/
/* swap_bbs */
/*------------------------------*/
VOID
swap_bbs()
{
BITBLK *where;
WORD num;
where = (BITBLK *) (head + ((RSHDR *) head)->rsh_bitblk);
num = ((RSHDR *) head)->rsh_nbb;
swap_bytes((BYTE *) where, num * sizeof(BITBLK));
for (; num--; where++)
swap_words((WORD *) &where->bi_pdata, sizeof(LONG));
}
/*------------------------------*/
/* swap_fstr */
/*------------------------------*/
VOID
swap_fstr()
{
BYTE *where;
WORD size;
where = head + ((RSHDR *) head)->rsh_frstr;
size = ((RSHDR *) head)->rsh_nstring * sizeof(LONG);
swap_bytes(where, size);
swap_words((WORD *) where, size);
}
/*------------------------------*/
/* swap_fimg */
/*------------------------------*/
VOID
swap_fimg()
{
LONG where;
WORD size;
where = head + ((RSHDR *) head)->rsh_frimg;
size = ((RSHDR *) head)->rsh_nimages * sizeof(LONG);
swap_bytes(where, size);
swap_words((WORD *) where, size);
}
/*------------------------------*/
/* close_files */
/*------------------------------*/
VOID
close_files()
{
if (r_hndl != -1)
Fclose(r_hndl);
if (d_hndl != -1)
Fclose(d_hndl);
if (r2_hndl != -1)
Fclose(r2_hndl);
if (d2_hndl != -1)
Fclose(d2_hndl);
r_hndl = d_hndl = r2_hndl = d2_hndl = -1;
}
/*------------------------------*/
/* do_conv */
/*------------------------------*/
WORD
do_conv()
{
BYTE *str;
LONG size;
WORD reply, nsym;
r_file[0] = '\0';
if (!get_file(old_rsc, r_file))
return;
if ((r_hndl = open_file(r_file)) == -1)
return;
if (conv_def)
{
new_ext(r_file, d_file, old_def);
FOREVER {
d_hndl = (WORD) Fopen(d_file, 0);
if (d_hndl >= 0)
break;
rsrc_gaddr(R_STRING, NODEF, &str);
reply = form_alert(1, str);
if (reply == 3)
{
close_files();
return;
}
if (reply == 1)
{
conv_def = FALSE;
break;
}
/* if (reply == 2) */
if (!get_file(old_def, d_file))
break;
}
}
graf_mouse(HOUR_GLASS, 0x0L);
beg_prog(&prog_rect)